package edu.pku.sei.transformation.editor.controller.commands.link;

import edu.pku.sei.transformation.editor.model.goal.GoalRelationship;
import edu.pku.sei.transformation.editor.model.goal.TransformationGoal;

public class GoalRelationshipCreateCommand
		extends
		AbstractLinkCreateCommand<GoalRelationship, TransformationGoal, TransformationGoal> {

	public GoalRelationshipCreateCommand(GoalRelationship link,
			TransformationGoal source) {
		super(link, source);
		if (link.getType() == GoalRelationship.TYPE_INCLUDE)
			this.setLabel("create include");
		else
			this.setLabel("create dependent");
	}

	@Override
	public void execute() {
		source.getRelationships().add(link);
		link.setSourceGoal(source);
		link.setTargetGoal(target);
	}

	@Override
	public void undo() {
		source.getRelationships().remove(link);
		link.setSourceGoal(null);
		link.setTargetGoal(null);
	}

}
